<?php
	define('access',true);
	require_once 'engine.php';
	session_start();	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
	<head>
		<title>BadASPTTStrasbourg dev-Engine</title>
		<meta http-equiv="Content-Language" content="fr">
		<!--[if IE]>
			<link rel="stylesheet" type="text/css" href="template/styles/ie.css"/>
		<![endif]-->
		<link rel="stylesheet" type="text/css" href="template/styles/main.css"/>
	</head>
	<body>
		<?php
		// On vérifie en permanence si la personne identifiée n'est pas bannie
		if (isset($_SESSION['userid'])):
				if(getBan($_SESSION['userid'])): 
					echo 'Il semblerait que vous ayez été banni';
					session_destroy();
				endif;
		endif;
		?>
		<div id="wrapper">
			<div id="header">
				<a href="http://badaspttstrasbourg.fr"><img src="template/images/logo.png" width="482px" height="124px"/></a>
				<div id="userdock">
					<?php
						if (isset($_GET['page'])):
							if ($_GET['page'] == 'login'):
								include 'control/login.php';
							endif;
							if ($_GET['page'] == 'logout'):
								include 'control/logout.php';
							endif;
						endif;
					?>
					<?php if (isset($_SESSION['userid'])){ ?>
						<ul>
							<li id="userdock-1"><a href="index.php?page=profil&profil_id=<?php echo $_SESSION['userid']; ?>&function=view">mon profil</a></li>
							<span id="userdock-sep-1"></span>
							<li id="userdock-2"><a href="index.php?page=comments&userid=<?php echo $_SESSION['userid']; ?>&function=view">mes commentaires</a></li>
							<span id="userdock-sep-2"></span>
							<li id="userdock-3"><a href="index.php?page=tournaments&userid=<?php echo $_SESSION['userid']; ?>&function=view">mes tournois</a></li>
							<span id="userdock-sep-3"></span>
							<li id="userdock-4"><a href="index.php?page=logout">se d&eacute;connecter</a></li>
						</ul>
						<div id="userdock-infos">
							<div id="avatar">
								<a href="index.php?page=profil&profil_id=<?php echo $_SESSION['userid']; ?>&function=view"><img src="images/avatars/avatar_<?php echo $_SESSION['userid']; ?>.jpg" width="100px" height="100px" /></a>
							</div>
						</div>
					<?php } else { ?>
						<form method="post" action="index.php?page=login">
							<input type="text" name="username" />
							<input type="password" name="userpass" />
							<input type="submit" value="Ok!" />
							<a href="index.php?page=register">S'inscrire</a>
						</form>
					<?php } ?>
				</div>
			</div>
			<div id="nav">
				<ul>
					<li><a href="index.php">Accueil</a></li>
					<li><a href="#">Le Club</a>
						<ul>
							<li><a href="#">Pr&eacute;sentation</a></li>
							<li><a href="#">Palmar&egrave;s</a></li>
							<li><a href="#">Le Comit&eacute;</a></li>
						</ul>
					</li>
					<li><a href="#">Informations</a></li>
					<li><a href="#">Interclubs</a></li>
					<li><a href="#">Tournois</a></li>
					<li><a href="#">Presse</a></li>
					<li><a href="#">Albums</a></li>
					<li><a href="index.php?page=contact">Contact</a></li>
					<li><a href="#">Masters 2010</a></li>
				</ul>
			</div>
			<div id="content">
				<div>
					<div style="background-color: orange;">Test Engine<br/>
						<?php echo 'Chargement de la librairie utilisateur: '; if (defined('libuser')){ echo '<span style="color: green;">{OK}</span>'; } else { echo '<span style="color: red;">{FAIL}</span>'; } ?>
							<br/>
						<?php echo 'Chargement de la librairie profil: '; if (defined('libprofil')){ echo '<span style="color: green;">{OK}</span>'; } else { echo '<span style="color: red;">{FAIL}</span>'; } ?>
							<br/>
						<?php echo 'Chargement de la librairie news: '; if (defined('libnews')){ echo '<span style="color: green;">{OK}</span>'; } else { echo '<span style="color: red;">{FAIL}</span>'; } ?>
							<br/>
						<?php echo 'Chargement de la librairie pagination: '; if (defined('libpagin')){ echo '<span style="color: green;">{OK}</span>'; } else { echo '<span style="color: red;">{FAIL}</span>'; } ?>
							<br/>
						<?php echo 'Chargement de la librairie mail: '; if (defined('libmail')){ echo '<span style="color: green;">{OK}</span>'; } else { echo '<span style="color: red;">{FAIL}</span>'; } ?>
					</div>
					<!-- DEV SECTOR -->
					<?php					
						if (isset($_GET['page'])){
							if ($_GET['page'] == 'register'): include 'model/register.php'; endif;
							if ($_GET['page'] == 'register'):
								if (isset($_GET['function'])):
									if ($_GET['function'] == 'verif'):
										include 'control/register.php';
									endif;
								endif;
							endif;
							if ($_GET['page'] == 'login'):
								echo 'Bienvenue '. $user->username;
							endif;
							if ($_GET['page'] == 'logout'):
								echo '&Agrave; bient&ocirc;t ;)';
							endif;
							if ($_GET['page'] == 'news'):
								if (isset($_GET['id'])){
									include 'model/billet.php';
								} elseif (isset($_GET['from'],$_GET['to'])){
									include 'model/news.php';
								} else {
									$_GET['from'] = 0; $_GET['to'] = $nbnews;
									include 'model/news.php';
								}
							endif;
							if ($_GET['page'] == 'profil'): 
								if ($_GET['function'] == 'view'): include 'model/profil.php'; endif;
								if ($_GET['function'] == 'edit'): include 'model/profil_edit.php'; endif;
							endif;
							if ($_GET['page'] == 'contact'):
								if (isset($_GET['function'])){
									if ($_GET['function'] == 'send'):
										include 'control/contact.php';
									endif;
								} else {
									include 'model/contact.php';
								}
							endif;
						} else {
							$_GET['from'] = 0; $_GET['to'] = $newsperpage;
							include 'model/news.php';
						}
					?>
				</div>
			</div>
			<div id="footer">
				<div id="copyright">
					<p>Designed and coded by <a href="#">&pound;lfaus</a></p>
					<p>Copyright &copy; 2011-2012 by <a href="#">&pound;lfaus</a> All Rights Reserved</p>
				</div>
				<div id="engine">
					<p>Powered by KeremOS</p>
				</div>
			</div>
		</div>
	</body>
</html>
